package org.magento.pages;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

//This class presents admin/sales_order/view/order_id/ page
public class OrderViewBeckEnd extends Page {

	//Locators:
	
	@FindBy(xpath = "/descendant::p[@class='form-buttons']/button[@title = 'Cancel']")
	public WebElement buttonCancel;
	
	//Actions:
	
	public OrdersBeckEnd cancelOrder() {
		buttonCancel.click();
		Alert alert =  driver.switchTo().alert();	 
		alert.accept();	 	   
		return PageFactory.initElements(driver, OrdersBeckEnd.class);
	}
	
	//Assertions:
	public boolean isOrderCreated() {
		return driver.findElement(By.cssSelector("BODY")).getText().contains("The order has been created.");
	}
	
	//Auto-generated:
	
	public OrderViewBeckEnd(WebDriver driver) {
		super(driver);
	}

	@Override
	public void open() {
	}
	
}
